<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        function reverse(arr){
            var newarr = [];
            if(arr instanceof Array){
                for(var i=arr.length-1;i>=0;i--){
                newarr[newarr.length] = arr[i];  
            }
            return newarr;
            }else{
                return 'error 错误，传入非数组'
            }
        }
        console.log(reverse([1,2,3]));
        console.log(reverse(1,2,3));

        //检测是否为数组
        var arr = new Array(1,2,3);
        console.log(arr instanceof Array);
        console.log(Array.isArray(arr));
    </script>
</body>
</html>